using System;
using System.IO;
using System.Net;
using System.Text;

namespace MingleReport.HttpRequests
{
    public abstract class AbstractMingleHttpRequest
    {
        protected HttpWebRequest httpRequest;
        protected readonly Encoding ENCODING = Encoding.GetEncoding(1252);
        protected readonly string server;
        public abstract string PostString { get; }
        public abstract void Create();


        protected AbstractMingleHttpRequest(string server)
        {
            this.server = server;
        }

        public virtual string GetResponse()
        {
            WebResponse httpResponse = httpRequest.GetResponse();
            Console.WriteLine(httpResponse.ResponseUri.ToString());
            string responseString;
            using (StreamReader reader = new StreamReader(httpResponse.GetResponseStream(), ENCODING))
            {
                responseString = reader.ReadToEnd();
            }
            return responseString;
        }
    }
}